package com.module.antiFake.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import base.dao.GenericHibernateDao;

import com.module.antiFake.vo.AntiFakeFile;
import com.util.PropertiesUtil;


public class AntiFakeFileDao extends GenericHibernateDao<AntiFakeFile,Integer>{
	private static String URL = "http://"+PropertiesUtil.getString("multimedia.url")+":"
	+PropertiesUtil.getString("multimedia.port")+PropertiesUtil.getString("multimedia.path");
	
	private AntiFakeFileDao(){
		
	}
	private static AntiFakeFileDao dao;
	public synchronized static AntiFakeFileDao getInstance(){
		if(dao == null){
			dao = new AntiFakeFileDao();
		}
		return dao;
	}
	
	
	@SuppressWarnings("unchecked")
	public List<AntiFakeFile> getUrl(Session session,int complainId ){
		String hql =" from AntiFakeFile as a where complainId="+complainId;
		Query query = session.createQuery(hql);
		List<AntiFakeFile> list=query.list();
		List<AntiFakeFile> newList = new ArrayList<AntiFakeFile>();
		for(AntiFakeFile a:list){
			a.setUrl(URL+"/"+a.getName());
			newList.add(a);
		}
		return newList;
	}
}
